#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
long long n,q;
long long x,y;
int main(void){
    //freopen("data.txt","r",stdin);
    scanf("%lld%lld",&n,&q);
    while(q--){
        scanf("%lld%lld",&x,&y);
        long long ans=0;
        if((x+y)%2){
            if(n%2){
                ans=(n*n/2)+1+n*((x-1)/2);
                if(x%2==0){
                    ans+=(n/2);
                }
                if(y%2){
                    ans+=(y+1)/2;
                }
                else{
                    ans+=(y/2);
                }

            }
            else{
                ans=n*n/2+(n/2)*(x-1);
                if(y%2){
                    ans+=(y+1)/2;
                }
                else{
                    ans+=(y/2);
                }
            }
        }
        else{
            if(n%2){
                ans=n*((x-1)/2);
                if(x%2==0){
                    ans+=(n/2)+1;
                }
                if(y%2){
                    ans+=(y+1)/2;
                }
                else{
                    ans+=(y/2);
                }

            }
            else{
                //n/2
                ans=(n/2)*(x-1);
                if(y%2){
                    ans+=(y+1)/2;
                }
                else{
                    ans+=(y/2);
                }
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}